package com.linzelin.dao;

import com.linzelin.pojo.Department;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * 部门们dao
 */
@Repository
//这个注解是表示这个是个Dao类,将这个类交给Spring托管
public class DepartmentDao {

    private static Map<Integer, Department> departments = null;

    static{
        departments = new HashMap<>();

        departments.put(101,new Department(101,"数学部"));
        departments.put(102,new Department(102,"语文部"));
        departments.put(103,new Department(103,"英语部"));
        departments.put(104,new Department(104,"学习部"));
    }

    public Collection<Department> getDepartment(){
        return departments.values();
    }

    public Department getDepartmentById(Integer id){
        return  departments.get(id);
    }
}
